package com.ms.game.sendgift.db;

import java.util.ArrayList;

import com.ms.game.itembox.db.ItemDAO;
import com.ms.game.itembox.db.PlayerItemModel;
import com.ms.game.lobby.GameLobbyModule;
import com.ms.game.sendgift.SendGiftProcessor;
import com.ms.game.sendgift.SendGiftStage;
import com.ms.game.sendgift.message.SendGiftResponse;
import com.ms.player.Player;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.service.module.task.TaskAsyncCommand;

/**
 * DC callback位置
 * @see SendGiftProcessor#OnSendGiftSecondAccept
 * @see SendGiftProcessor#OnSendGiftFinialAccept
 */
public class LoadSendGiftOrderAsync extends TaskAsyncCommand {

	public GUID sessionID;
	
	public GUID playerID;
	
	public String playerName;
	
	public Player playerData;
	
	public String playerIP;
	
	/**
	 * 送禮物訂單ID
	 */
	public long orderID;
	
	public GameLobbyModule module;
	
	public SendGiftResponse response;
	
	/**
	 * 現在的處理階段
	 */
	public int stage;
	
	/**
	 * 撈回的資料
	 */
	private SendGiftNotifyModel model;
	
	/**
	 * 取回的寄送道具清單
	 */
	private ArrayList<PlayerItemModel> sendGiftItems;
	
	@Override
	public void asyncExecute() throws Exception {
		model = SendGiftDAO.loadSendGiftNotifyModelByOrderID(orderID);
		
		// 取回寄送道具清單
		if (model != null) {
			sendGiftItems = ItemDAO.loadSendGiftItems(model.getOrderID());
		}
	}

	@Override
	public void execute() throws Exception {
		/*if(stage == SendGiftStage.SECOND_ACCEPT){
			//對方確認階段
			SendGiftProcessor.OnSendGiftSecondAcceptCallBack(sessionID, playerID, playerName, playerIP, model, response, module);
		}else */
		if(stage == SendGiftStage.FINIAL_SEND){
			//最後階段
			//SendGiftProcessor.OnSendGiftFinialAcceptCallBack(sessionID, playerID, playerName, playerData, playerIP, model, sendGiftItems, response, module);
		}
	}

	public SendGiftNotifyModel getModel() {
		return model;
	}

	public ArrayList<PlayerItemModel> getSendGiftItems() {
		return sendGiftItems;
	}
}
